package com.dries.portal.module.convener.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.Objects;
import java.util.stream.Stream;

/**
 * @Description:
 * @Author ZSY
 * @createTime 2020/9/23 18:55
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
public enum ConvenerPaymentType {

    AA(1, "AA制"),
    QINGKE(2, "请客")
    ;

    @EnumValue
    private Integer code;
    private String description;

    @JsonValue
    public String getDescription() {
        return description;
    }

    /** 根据code获取到CouponStatus */
    public static ConvenerPaymentType of(Integer code) {
        Objects.requireNonNull(code);
        return Stream.of(values()).filter(e -> e.getCode().equals(code))
                .findAny()
                .orElseThrow(() -> new IllegalArgumentException(code + "not exists!"));
    }

}
